﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>开发者审核</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="demo.css" rel="stylesheet" type="text/css" />

    <script src="../scripts/boot.js" type="text/javascript"></script>
</head>
<body>
    <h1>开发者审核</h1>      

    <div style="width:800px;">
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                        <a class="mini-button" iconCls="icon-add" onclick="edit()">编辑</a>     
                    </td>
                    <td style="white-space:nowrap;">
                    	<select id="keyType">
                    		<option value="username">用户名</option>
                    		<option value="appURL">AppURL</option>
                    	</select>
                    </td>
                    <td style="white-space:nowrap;">
                        <input id="key" class="mini-textbox" emptyText="请输入账号" style="width:150px;" onenter="onKeyEnter"/>   
                        <a class="mini-button" onclick="search()">查询</a>
                    </td>
                </tr>
            </table>           
        </div>
    </div>
    <div id="datagrid1" class="mini-datagrid" style="width:auto;height:360px;" allowResize="true"
        url="../admin/admin_listUsers"  idField="id" multiSelect="true" 
    >
        <div property="columns">     
            <div field="username" width="120" headerAlign="center" >开发者账号</div> 
            <div field="password" width="120" headerAlign="center">密码</div>    
            <div field="appURL" width="120" headerAlign="center" allowResize="true">appURL</div>
            <div field="queryRight" width="120" headerAlign="center" >通过审核</div>
        </div>
    </div>
    

    <script type="text/javascript">
        mini.parse();

        var grid = mini.get("datagrid1");
        grid.load({cqr:true});

        
        function add() {
            
            mini.open({
                url: bootPATH + "../admin/userForm.html",
                title: "新增开发者", width: 400, height: 220,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "new"};
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {

                    grid.reload({qrc:true});
                }
            });
        }
        function edit() {
         
            var row = grid.getSelected();
            if (row) {
                mini.open({
                    url: bootPATH + "../admin/userForm.html",
                    title: "编辑开发者", width: 600, height: 360,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "edit", username: row.username };
                        iframe.contentWindow.SetData(data);
                        
                    },
                    ondestroy: function (action) {
                        grid.reload();
                        
                    }
                });
                
            } else {
                alert("请选中一条记录");
            }
            
        }
        function remove() {
            
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                if (confirm("确定删除选中记录？")) {
                    var ids = [];
                    for (var i = 0, l = rows.length; i < l; i++) {
                        var r = rows[i];
                        ids.push(r.username);
                    }
                    var id = ids.join(',');
                    grid.loading("操作中，请稍后......");
                    $.ajax({
                        url: "../admin/admin_deleteUsers?ids=" +id,
                        dataType:"json",
                        success: function (text) {
                            grid.reload();
                        },
                        error: function () {
                        }
                    });
                }
            } else {
                alert("请选中一条记录");
            }
        }
        function search() {
            var key = mini.get("key").getValue();
            var keyType = $("#keyType").val();
            grid.load({cqr:true, key: key,keyType:keyType},function(json){
            	if(json.total == 0)
            		mini.alert("无数据")
            },null);
        }
        function onKeyEnter(e) {
            search();
        }
        $(function(){
        	$("#keyType").change(function(){
        		$("#key input").attr("placeholder","请输入" + $("#keyType").find("option:selected").text())
        	})
        })

    </script>
</body>
</html>